//
//  UIColor+WDColorExtension.m
//  Zhihuijinfu
//
//  Created by 王笛 on 2016/12/16.
//  Copyright © 2016年 王笛. All rights reserved.
//

#import "UIColor+WDColorExtension.h"

@implementation UIColor (WDColorExtension)

+ (UIColor *)getColorFromString:(NSString *)colorStr
{
    unsigned int alpha, red, green, blue;
    NSRange range;
    range.length =2;
    
    range.location =1;
    [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&alpha];//透明度
    range.location =3;
    [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&red];
    range.location =5;
    [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&green];
    range.location =7;
    [[NSScanner scannerWithString:[colorStr substringWithRange:range]]scanHexInt:&blue];
    return [UIColor colorWithRed:(float)(red/255.0f)green:(float)(green/255.0f)blue:(float)(blue/255.0f)alpha:(float)(alpha/255.0f)];
}

@end
